// vue中mixins(混入)的使用
// https://blog.csdn.net/weixin_43638968/article/details/108665092?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-1.highlightwordscore&spm=1001.2101.3001.4242.2

export default{
	data(){
		return{ 
			winWid:0,
			winHei:0,
			myToken:"",
			money_addr:""//钱包地址
		}
	}, 
	mounted() {
		let that=this;
		this.getWinWid();
		this.getWinHei();
		//console.log("winWid:",this.winWid);
		//console.log("winHei:",this.winHei);
		 
		
		window.addEventListener('resize',()=>{
		  that.getWinWid();
		  that.getWinHei();
		})
	},
	activated(){
		let that=this;
		// that.getsessionStorageFn();
	},
	
	methods:{
		getFirstRefresh(){
			
		},
		getsessionStorageFn(){
			this.myToken=window.sessionStorage.getItem("webToken");
			//console.log("this.myToken:",this.myToken);
		},
		getWinWid(){
			this.winWid=document.documentElement.clientWidth||document.body.clientWidth;
		},
		getWinHei(){
			this.winHei=document.documentElement.clientHeight||document.body.clientHeight;
		},
		goPage(val){
			this.$router.push({path:val});
		},
		goBackFn(){
			this.$router.go(-1);
		},
		// loginFn(){ 
		// 	//alert("拿参数："+window.location.href.split("?")[1].split("=")[1]); 
		// 	console.log("调用了loginFn");
		// 	let that=this;  
			 
		// 	  //console.log("window.tronWeb.defaultAddress.base5890:",window.tronWeb.defaultAddress.base58); 
		// 		if(!window.tronWeb){
		// 			console.log("无window.tronWeb");
		// 			if(this.$i18n.locale=='cn'){
		// 				that.$bus.$emit("toastEvent","未检测到钱包,无法登录!");
		// 			}else{
		// 				that.$bus.$emit("toastEvent","No wallet detected, unable to login!");
		// 			}
		// 			 that.$bus.$emit("tipMaskEvent",true); 
		// 			return false;
		// 		}else{ 
		// 			console.log("有window.tronWeb");
		// 		  if(window.tronWeb && window.tronWeb.defaultAddress.base58){ 
		// 			  that.money_addr=window.tronWeb.defaultAddress.base58;
				 
		// 			  console.log("that.money_addr_123:",that.money_addr); 
					  
		// 			  const myToken=window.sessionStorage.getItem("webToken");
		// 			  console.log("myToken111:",myToken); 
					  
		// 			  if(!myToken){
		// 				  console.log("需要登录!");
		// 				//that.$bus.$emit("需要登录!");  
						
		// 				console.log("有join");
		// 				let myParamsjoin;
		// 				let paramsObj;
						
		// 			 if(window.location.href.indexOf("invite")!==-1){  //含有join
		// 				 // 不止一个参数 (含有join)
		// 				 if(window.location.href.indexOf("&")!==-1){ 
						 	 
		// 				 	paramsObj= window.location.href.split("?")[1].split("&");
						 	
		// 				 	let new_paramsObj={};
						 	
		// 				 	 that.$bus.$emit("toastEvent",paramsObj); 
						 	  
		// 				 	  for(let i of paramsObj){
		// 				 		  console.log("i参数对象：",i);
		// 				 		  new_paramsObj[i.split("=")[0]]=i.split("=")[1]; 
		// 				 	  }
		// 				 	  console.log("new_paramsObj:",new_paramsObj);
						 	  
		// 				 	  myParamsjoin=new_paramsObj["invite"];
						 	
		// 				 }else{ // 只有一个参数为join
						 
						 	 
		// 				 	myParamsjoin=window.location.href.split("?")[1].split("=")[1];
		// 				 } // if结束
						 
		// 			 } // if结束
						
						
						
						
		// 					//that.$bus.$emit("toastEvent",myParamsjoin);
		// 					//登录请求开始
							
		// 					this.$request.post(
		// 					           `/api/myuser/reglog?lang=`,
		// 					           {
		// 					              address:that.money_addr,
		// 					              invite:myParamsjoin
		// 					           } 
		// 					         )
		// 							 .then(res=>{
		// 							 	console.log("请求成功",res.data.msg);
									 	 
									 						
		// 							 	  if(res.data.code==1){
		// 									  window.sessionStorage.setItem("webToken",true);
		// 							 		that.myToken=true; 
		// 							 		that.$bus.$emit("tipMaskEvent",false);				 
		// 							 		console.log("that.myToken:",that.myToken);
									 								 
		// 							 		  return true;
		// 							 	  }else{
		// 									  that.$bus.$emit("toastEvent",res.data.msg);
		// 							 		  window.sessionStorage.removeItem("webToken");
		// 							 		  return false;
		// 							 	  }
									 						 
		// 							 })
		// 							 .catch(err=>{
		// 							 	   console.log("登录请求失败",err);
		// 							 	   window.sessionStorage.removeItem("webToken");
		// 							 	   return false;
		// 							 });
							
							 
		// 					//登录请求结束
						
							 
		// 			  }else{
		// 				  console.log("不需要登录!");
		// 				  return true;
		// 			  } 
		// 		  }else{ // alert(2)
		// 			  window.sessionStorage.removeItem("webToken");
		// 		      that.$bus.$emit("toastEvent","未检测到钱包,无法登录!"); 
					  
		// 			  that.$bus.$emit("tipMaskEvent",true);
		// 			  return false; 
		// 		  }
				  
		// 	    } // window.tronWeb 结束
			 
			 
		// }
	}
}